package com.itao.util;

import java.net.URL;
import java.util.Objects;

/**
 * @Author sjt
 * @CreateTime 2023/10/16 9:57
 */
public class ResourceUtil {

    public static String getClassPath(Class<?> cls) {
        var url =
                Objects.requireNonNullElse(cls, ResourceUtil.class)
                        .getClassLoader().getResource("");
        if (url == null) {
            throw new NullPointerException();
        }
        return url.getPath();
    }

    public static String getClassPath() {
        return getClassPath(null);
    }
}
